package com.sub.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sub.dao.IUserDao;
import com.sub.dbRouting.annotation.Router;
import com.sub.dbRouting.annotation.RwRouter;
import com.sub.pojo.User;
import com.sub.service.IUserService;

@Service("userService")
public class UserServiceImpl implements IUserService {

	@Resource
	private IUserDao dao;

	@Override
	@Router(routClass = User.class)
	public boolean insert(User user) {
		if (user != null)
			dao.insert(user);
		if (user.getId() != null)
			return true;
		return false;
	}

	@Override
	@Router(routClass = User.class)
	public boolean update(User user) {
		if (user != null) {
			dao.update(user);
			return true;
		}
		return false;
	}

	@Override
	@Router(routClass = User.class)
	public boolean delete(User user) {
		if (user != null) {
			dao.delete(user);
			return true;
		}
		return false;
	}

	@Override
	@RwRouter("select")
	public User select(User user) {
		if (user != null) {
			return dao.select(user);
		}
		return null;
	}

}
